
import Player from "../reserve/Player";
import GameMain from "./GameMain";

const {ccclass, property} = cc._decorator;

@ccclass
export default class Aircraft extends Player {

    protected start(): void {
        this.node.setPosition(new cc.Vec2(0, -100));
    }


    shootBullet(){
        if (GameMain.running && this.timer - this.shootSpeed > 0) {
            this.timer = 0;
            var loadobj =cc.instantiate(this.bullet);//将预制体克隆到场景
            this.node.parent.addChild(loadobj);//将克隆出的物体作为子物体
            loadobj.setPosition(cc.v2(this.node.x,this.node.y));
        }
    }


    onCollisionEnter(other, self) {
        console.log("玩家碰撞")
        // 如果碰撞到敌人，直接销毁自身
        // 如果碰撞到子弹的检查在敌军子弹上
        if (other.node.group == "enemy") {
            GameMain.running = false;
        }
    }

    protected onDestroy(): void {
        // 自身销毁时的处理事件
        // 销毁动画
    }
}
